﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using TimeTracker.Provider;
using Utility;
using Utility.Windows.Forms;
using System.Windows.Forms;
using System.ComponentModel;

namespace TimeTracker
{
    public partial class TreeViewLog
    {
        protected delegate void SkinTreeCallBack(TreeNode node);

        protected void SkinTree()
        {
            foreach (TreeNode node in this.treeView1.Nodes)
            {
                this.SkinNodeAndChildren(node);
            }
        }
        
        protected void SkinNodeAndParents(TreeNode node)
        {
            while (node != null)
            {
                this.SkinNode(node);
                node = node.Parent;
            }
        }

        protected void SkinNodeAndChildren(TreeNode node)
        {
            this.SkinNode(node);

            foreach (TreeNode childNode in node.Nodes)
            {
                this.SkinNodeAndChildren(childNode);
            }
        }

        protected void SkinNode(TreeNode node)
        {
            if (node.Tag == null) { return; }

            GroupByEnumeration groupBy = this.IsGroupByProject ? GroupByEnumeration.Project : GroupByEnumeration.Date;

            SkinManager.Instance.SkinNode(node, groupBy);
        }

    }
}
